MODE_ANICAMERA = {}
MODE_ANICAMERA.PrevCamera = null
MODE_ANICAMERA.CurrentName = ""

function MODE_ANICAMERA:Think(player, trace)
	if SERVER then
	end
end

function MODE_ANICAMERA:LeftClick(player, trace)

	local entity = ents.Create( "animated_camera" )
	if(entity and entity:IsValid()) then
	
		entity:PhysicsInit(SOLID_VPHYSICS)
		entity:SetMoveType(MOVETYPE_VPHYSICS)
		entity:SetPos(trace.StartPos)
		entity:SetAngles(player:GetAngles())
		
		entity:Spawn()

		local tangentScalar = 20.0
		if MODE_ANICAMERA.PrevCamera then
			tangentScalar = MODE_ANICAMERA.PrevCamera:GetPos():Distance(entity:GetPos()) / 3
		end

		entity.BaseClass.SetCurveTangent(entity, (player:GetAimVector() * tangentScalar))
		entity.BaseClass.SetName(entity, MODE_ANICAMERA.CurrentName)
		entity:InitalizeChain(MODE_ANICAMERA.PrevCamera)

		MODE_ANICAMERA.PrevCamera = entity

			  
		local physicsObject = entity:GetPhysicsObject()
		if physicsObject and physicsObject:IsValid() then
			physicsObject:Wake()
		end

	end
end

function MODE_ANICAMERA:RightClick(player, trace)
	
end
/*********************************************************************************************************/

MODE_CAMERAGATHERSEQUENCE = {}
MODE_CAMERAGATHERSEQUENCE.TargetCamera = nil

function MODE_CAMERAGATHERSEQUENCE:Think(player, trace)

end

function MODE_CAMERAGATHERSEQUENCE:LeftClick(player, trace)
	if trace.HitNonWorld then
		print("Leftclicking in mode..") 

		local sequence = trace.Entity
		if sequence and sequence:IsValid() and (sequence:GetClass() == "actor_sequence") then
			local sequenceRoot = sequence.BaseClass.GetRootNode(sequence)
			if sequenceRoot and sequenceRoot:IsValid() then
				print("Sequence entity valid, sending data..") 
				local TargetCamera = MODE_CAMERAGATHERSEQUENCE.TargetCamera
				print("TargetCamera = ",TargetCamera )
				datastream.Send( player, "AnimatedCamera_AssignSequence", {RecipientEntIdx = TargetCamera:EntIndex(), SequenceEntIdx = sequenceRoot:EntIndex()} ,nil)
			end
		end
	end
end

function MODE_CAMERAGATHERSEQUENCE:RightClick(player, trace)
	
end

/*************************************************************************************************************/
MODE_STATIC_CAMERA = {}
MODE_STATIC_CAMERA.CurrentName = ""

function MODE_STATIC_CAMERA:Think(player, trace)
	
end

function MODE_STATIC_CAMERA:LeftClick(player, trace)
	
end

function MODE_STATIC_CAMERA:RightClick(player, trace)

end
